package xyz.xtt.admin.constants;

import org.jetbrains.annotations.NotNull;

import java.util.*;

public enum PayUnitEnum {
	TONG_BAO(1, "通宝支付"), TZ(2, "通钻"), CASH(3, "现金支付");

	private int code;
	private String desc;

	// 构造函数
	private PayUnitEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	// 获取描述
	public String desc() {
		return desc;
	}

	public static PayUnitEnum convert(String checkType) {
		return Arrays.asList(PayUnitEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst()
				.orElse(null);
	}

	public static PayUnitEnum queryConvert(int checkType) {
		return Arrays.asList(PayUnitEnum.values())
				.stream().filter(x -> Objects.equals(x.code(), checkType))
				.findFirst()
				.orElse(null);
	}
}
